package com.example.xlzx.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xlzx.entity.AboutUs;
import com.example.xlzx.entity.ContactUs;
import com.example.xlzx.result.Result;
import com.example.xlzx.service.IAboutUsService;
import com.example.xlzx.service.IContactUsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 联系我们表 前端控制器
 * </p>
 *
 * @author 1
 * @since 2025-03-07
 */
@RestController
@Tag(name="联系我们信息")
@RequestMapping("/xlzx")
public class ContactUsController {
    @Autowired
    private IContactUsService contactUsService;
    @Operation(summary = "新增联系我们")
    @PostMapping("/insetContactUs")
    public Result<Boolean> insertContactUs(@RequestBody ContactUs contactUs) {
        return Result.ok(contactUsService.save(contactUs));
    }

    @Operation(summary = "根据id删除联系我们")
    @DeleteMapping("/deleteContactUs/{id}")
    public Result<Boolean> deleteContactUs(@PathVariable Long id) {
        return Result.ok(contactUsService.removeById(id));
    }

    @Operation(summary = "修改联系我们")
    @PutMapping("/updateContactUs")
    public Result<Boolean> updateContactUs(@RequestBody ContactUs contactUs) {
        return Result.ok(contactUsService.updateById(contactUs));
    }

    @Operation(summary = "根据id查询联系我们信息")
    @GetMapping("/getContactUsInfo/{id}")
    public Result<ContactUs> getContactUsInfo(@PathVariable Long id) {
        return Result.ok(contactUsService.getById(id));
    }

    @Operation(summary = "联系我们分页查询")
    @GetMapping("/selectContactUs/page")
    public Result<Page<ContactUs>> selectContactUs(@RequestParam int page, @RequestParam int size) {
        Page<ContactUs> pageParam = new Page<>(page, size);

        return Result.ok(contactUsService.page(pageParam));
    }
}
